package csmaster

import (
	"net/http"
)

func startHttpService(port string) error {
	log.Println("brickyard csmaster listens on ", port, "...")
	http.HandleFunc("/", rootHandler)
	http.HandleFunc("/addaccount", addAccountHandler)
	http.HandleFunc("/stataccount", statAccountHandler)

	err := http.ListenAndServe(":"+port, nil)
	return err
}

func rootHandler(w http.ResponseWriter, req *http.Request) {
	log.Println(req.Method + "--" + req.RequestURI)
	io.WriteString(w, "brickyard csmaster")
}

func addAccountHandler(w http.ResponseWriter, r *http.Request)  {}
func delAccountHandler(w http.ResponseWriter, r *http.Request)  {}
func statAccountHandler(w http.ResponseWriter, r *http.Request) {}

//e.g. total count of accounts
func statOverallHandler(w http.ResponseWriter, r *http.Request) {}

//todo, auth functionality, may be not via http
func authHandler(w http.ResponseWriter, r *http.Request) {}
